﻿function submitCode(pid) {
	if (refreshWin('submitCode' + pid)) return;
	if (sys.guest)
		showLogin(onload);
	else
		onload();

	function onload() {
		var txtpid = new Ext.form.TextField({
					anchor : '95%',
					fieldLabel : 'PID',
					name : 'pid',
					readOnly : true,
					value : pid
				});
		/*
		 * var title = new Ext.form.TextField({ anchor : '95%', fieldLabel :
		 * '标题', name : 'title', readOnly : true });
		 */
		var lang = new Ext.form.ComboBox({
					anchor : '50%',
					fieldLabel : '语言',
					hiddenName : 'lang',
					mode : 'local',
					triggerAction : 'all',
					valueField : 'code',
					displayField : 'title',
					editable : false,
					allowBlank : false,
					store : new Ext.data.Store({
								autoLoad : true,
								url : url.getLangList,
								reader : new Ext.data.JsonReader({
											root : 'result',
											id : 'code'
										}, ['code', 'title'])
							}),
					validator : function(v) {
						if (Ext.isEmpty(v) || v == '　') return '请选择语言';
						return true;
					}
				});
		var code = new Ext.form.TextArea({
					fieldLabel : '代码',
					name : 'code',
					allowBlank : false,
					anchor : '95% -55'
				});

		var form = new Ext.FormPanel({
					labelAlign : 'right',
					labelWidth : 40,
					frame : true,
					items : [txtpid, lang, code],
					fbar : new Ext.Toolbar({
								items : [new Ext.Button({
											iconCls : 'ok-icon',
											text : '提交',
											handler : onSubmit
										})]
							})
				});
		var win = new Ext.Window({
					iconCls : 'submit-icon',
					id : 'submitCode' + pid,
					title : '提交代码-' + pid,
					manager : ui.windows,
					layout : 'fit',
					width : 600,
					height : 400,
					minWidth : 380,
					minHeight : 230,
					items : form
				});
		win.show();
		function onSubmit() {
			if (!form.getForm().isValid()) {
				alertx('请正确输入数据！');
				return;
			}
			ajaxform({
						form : form,
						url : url.submitCode,
						success : function(obj) {
							showStatusList(1);
							win.close();
						}
					});
		}
	}
}
